<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<script type="text/javascript">
    var userobj;
    var did;
    $(function() {

        $('#userAddorganizationId').combotree({
            url : '${path }/org/orgTree',
            lines : true,
            panelHeight : 'auto',
            valueField:'id',
            textField:'text',
            onChange: function (newValue, oldValue) {
                var url= '${path }/org/getdepartmentlist?id='+newValue;
                $('#userAddDepartment').combobox('reload',url);
            }


        });

        $('#userEditRoleIds').combobox({
            url : '${path }/role/getrolelist',
            panelHeight : 'auto',
            multiple : true,
            required : true,
            valueField:'id',
            textField:'text',

        });
       //var oid=$('#userEditorganizationId').combotree("getValue");

        $('#userAddDepartment').combobox({
            url : '',
            panelHeight : 'auto',
            valueField:'id',
            textField:'name',
            onChange: function (newValue, oldValue) {
                var url= '${path }/position/getposlist?id='+newValue;
                $('#userPosition').combobox('reload',url);


            }

        });
        var   peid=$('#userDepartment').combobox("getValue");

        $('#userPosition').combobox({
            url : '',
            panelHeight : 'auto',

            required : true,
            valueField:'id',
            textField:'name'



        });

        $('#userAddForm').form({
            url : '${path }/user/add',

            onSubmit : function() {
                progressLoad();

                var isValid = $(this).form('validate');

                if (!isValid) {
                    progressClose();
                }

                return isValid;
            },
            success : function(result) {
                progressClose();
                result = $.parseJSON(result);
                if (result.success) {
                    parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
                    parent.$.modalDialog.handler.dialog('close');
                } else {
                    parent.$.messager.alert('错误', result.msg, 'error');
                }
            }
        });

    });
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',border:false" title="" style="overflow: hidden;padding: 3px;">
        <form id="userAddForm" method="post">

            <table class="grid">
                <tr>
                    <td>登录名</td>
                    <td><input name="id" type="hidden" >
                        <input name="loginname" type="text" placeholder="请输入登录名称" class="easyui-validatebox" data-options="required:true" ></td>
                    <td>姓名</td>
                    <td><input name="realname" type="text" placeholder="请输入姓名" class="easyui-validatebox" data-options="required:true"  ></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input  name="password" type="password"  class="easyui-validatebox" data-options="required:true" /></td>
                    <td>确认密码</td>
                    <td><input  name="repassword" type="password" class="easyui-validatebox" data-options="required:true,validType:'eqPwd[\'#userAddForm input[name=password]\']'"/></td>
                </tr>

                <tr>
                    <td>单位</td>
                    <td><select id="userAddorganizationId" name="orgs" style="width: 140px; height: 29px;"   ></select></td>
                    <td>角色</td>
                    <td><input  id="userEditRoleIds" name="roles" style="width: 140px; height: 29px;" class="easyui-combobox"  /></td>
                </tr>
                <tr>
                    <td>部门</td>
                    <td><select id="userAddDepartment" name="departmentid"  style="width: 140px; height: 29px;" class="easyui-combobox"  ></select></td>
                    <td>岗位</td>
                    <td><select id="userPosition" name="positionid" style="width: 140px; height: 29px;" class="easyui-combobox" data-options="required:true" >

                    </select></td>
                </tr>
                <tr>
                    <td>职务称谓</td>
                    <td><input type="text" name="worktitle" /></td>
                    <td>性别</td>
                    <td><select id="userEditSex" name="sex" class="easyui-combobox" data-options="width:140,height:29,editable:false,panelHeight:'auto'">
                        <option value="0">男</option>
                        <option value="1">女</option>
                    </select></td>
                </tr>
                <tr>
                    <td>电话</td>
                    <td>
                        <input type="text" name="phone" class="easyui-numberbox" />
                    </td>
                    <td>用户类型</td>
                    <td><select id="userEditStatus" name="status" class="easyui-combobox" data-options="width:140,height:29,editable:false,panelHeight:'auto'">
                        <option value="0">正常</option>
                        <option value="1">停用</option>
                    </select></td>
                </tr>

            </table>
        </form>
    </div>
</div>